PROJECT(bergamote)
cmake_minimum_required(VERSION 2.6)
ENABLE_TESTING()
include (version.cmake)
message(STATUS "*** Building bergamote ${bergamote_VERSION} ***")
#set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

find_package(PkgConfig REQUIRED)

OPTION(ENABLE_GTKMM "Enable gtkmm library" OFF)
OPTION(ENABLE_LIBXMLPP "Enable libxml++" OFF)

IF (ENABLE_GTKMM)
  pkg_check_modules(GTKMM REQUIRED gtkmm-2.4)
ENDIF (ENABLE_GTKMM)

IF (ENABLE_LIBXMLPP)
  pkg_check_modules(LIBXMLPP REQUIRED libxml++-2.6)
ENDIF (ENABLE_LIBXMLPP)



IF (ENABLE_GTKMM)
  IF (GTKMM_FOUND)
    message(STATUS "gtkmm was found")
  ELSE (GTKMM_FOUND)
    message(STATUS "gtkmm was not found")
  ENDIF (GTKMM_FOUND)
ENDIF (ENABLE_GTKMM)


set(LIBRARY_OUTPUT_PATH ${PostNurbsAbaqus_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${PostNurbsAbaqus_BINARY_DIR}/bin)

include_directories(${LIBXMLPP_INCLUDE_DIRS} mathobject/include elements/include)


#FIND_PACKAGE(blabla REQUIRED)
ADD_SUBDIRECTORY(mathobject)
ADD_SUBDIRECTORY(geometry)
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(elements)
ADD_SUBDIRECTORY(random)
ADD_SUBDIRECTORY(signal)
ADD_SUBDIRECTORY(results)
IF (ENABLE_GTKMM)
  ADD_SUBDIRECTORY(gui)
ENDIF (ENABLE_GTKMM)

ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(utils)

configure_file(config.h.cmake config.h)

SET(bergamote_src bergamote.cpp)
ADD_EXECUTABLE(bergamote ${bergamote_src})

if (ENABLE_GTKMM)
  add_definitions(-DENABLE_GTKMM)
  if (ENABLE_LIBXMLPP)
    add_definitions(-DENABLE_LIBXMLPP -DENABLE_GTKMM)
    SET_TARGET_PROPERTIES(bergamote PROPERTIES COMPILE_FLAGS ${LIBXMLPP_CFLAGS} COMPILE_FLAGS ${GTKMM_CFLAGS})
  else (ENABLE_LIBXMLPP)
    set_target_properties(bergamote PROPERTIES COMPILE_FLAGS ${GTKMM_CFLAGS})
  endif (ENABLE_LIBXMLPP)
else (ENABLE_GTKMM)
  if (ENABLE_LIBXMLPP)
    add_definitions(-DENABLE_LIBXMLPP)
    SET_TARGET_PROPERTIES(bergamote PROPERTIES COMPILE_FLAGS ${LIBXMLPP_CFLAGS})
  endif (ENABLE_LIBXMLPP)
endif (ENABLE_GTKMM)


TARGET_LINK_LIBRARIES(bergamote  ${LIBXMLPP_LIBRARY_DIRS} ${GTKMM_LIBRARY_DIRS} mathobject geometry elements random signal results  utils)
